package mobilefeel.dto;

/**
 * An AccelerometerEvent instance contains information about an accelerometer
 * event produced by an Android device.
 * <p>
 * The coordinate-system is defined relative to the screen of the device in its
 * default orientation. The axes are not swapped when the device's screen
 * orientation changes. 
 * <p>
 * The X axis is horizontal and points to the right, the Y axis is vertical and
 * points up and the Z axis points towards the outside of the front face of the
 * screen. In this system, coordinates behind the screen have negative Z values.
 * <p>
 * A sensor of this type measures the acceleration applied to the device (Ad).
 * Conceptually, it does so by measuring forces applied to the sensor itself
 * (Fs) using the relation:<br>
 * <p><code> Ad = - sum(Fs) / mass </code></p>
 * In particular, the force of gravity is always influencing the measured
 * acceleration:<br>
 * <p><code> Ad = -g - sum(F) / mass </code></p>
 * For this reason, when the device is sitting on a table (and obviously not
 * accelerating), the accelerometer reads a magnitude of g = 9.81 m/s^2.
 * Similarly, when the device is in free-fall and therefore dangerously
 * accelerating towards to ground at 9.81 m/s^2, its accelerometer reads a
 * magnitude of 0 m/s^2.
 * <p>
 * Examples:<br>
 * - When the device lies flat on a table and is pushed on its left side toward
 * the right, the x acceleration value is positive.<br>
 * - When the device lies flat on a table, the acceleration value is +9.81,
 * which correspond to the acceleration of the device (0 m/s^2) minus the force
 * of gravity (-9.81 m/s^2).<br>
 * - When the device lies flat on a table and is pushed toward the sky with an
 * acceleration of A m/s^2, the acceleration value is equal to A+9.81 which
 * correspond to the acceleration of the device (+A m/s^2) minus the force of
 * gravity (-9.81 m/s^2).<br>
 */
public class AccelerometerEvent extends DataTransferObject {

	private static final long serialVersionUID = 1L;

	private int accuracy;
	private long timestamp;
	private float x;
	private float y;
	private float z;
	private float maxRange;
	private float resolution;

	/**
	 * Returns the accuracy of the event.
	 * 
	 * @return an integer value containing the event's accuracy
	 */
	public int getAccuracy() {
		return accuracy;
	}
	
	/**
	 * Sets the accuracy of the event.
	 * 
	 * @param accuracy an integer value containing the event's accuracy
	 */
	public void setAccuracy(int accuracy) {
		this.accuracy = accuracy;
	}
	
	/**
	 * Returns the time at which the event happened, in nanoseconds.
	 * 
	 * @return a long value containing the time in nanoseconds
	 */
	public long getTimestamp() {
		return timestamp;
	}
	
	/**
	 * Sets the time at which the event happened, in nanoseconds.
	 * 
	 * @param timestamp a long value containing the time in nanoseconds
	 */
	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}
	
	/**
	 * Returns the device's acceleration minus Gx on the x-axis, in SI units
	 * (m/s^2).
	 * 
	 * @return a float value containing the x-axis acceleration
	 */
	public float getX() {
		return x;
	}
	
	/**
	 * Sets the device's acceleration on the x-axis.
	 * 
	 * @param x a float value containing the x-axis acceleration
	 */
	public void setX(float x) {
		this.x = x;
	}
	
	/**
	 * Returns the device's acceleration minus Gy on the y-axis, in SI units
	 * (m/s^2).
	 * 
	 * @return a float value containing the y-axis acceleration
	 */
	public float getY() {
		return y;
	}
	
	/**
	 * Sets the device's acceleration on the y-axis.
	 * 
	 * @param y a float value containing the y-axis acceleration
	 */
	public void setY(float y) {
		this.y = y;
	}
	
	/**
	 * Returns the device's acceleration minus Gz on the z-axis, in SI units
	 * (m/s^2).
	 * 
	 * @return a float value containing the z-axis acceleration
	 */
	public float getZ() {
		return z;
	}
	
	/**
	 * Sets the device's acceleration on the z-axis.
	 * 
	 * @param z a float value containing the z-axis acceleration
	 */
	public void setZ(float z) {
		this.z = z;
	}
	
	/**
	 * Returns the device's accelerometer sensor maximum range.
	 * 
	 * @return a float value containing the accelerometer's maximum range
	 */
	public float getMaxRange() {
		return maxRange;
	}

	/**
	 * Returns the device's accelerometer sensor resolution.
	 * 
	 * @return a float value containing the accelerometer's resolution
	 */
	public float getResolution() {
		return resolution;
	}

	/**
	 * Sets the device's accelerometer maximum range.
	 * 
	 * @param maxRange a float value containing the accelerometer's maximum
	 * range
	 */
	public void setMaxRange(float maxRange) {
		this.maxRange = maxRange;
	}

	/**
	 * Sets the device's accelerometer sensor resolution.
	 * 
	 * @param resolution a float value containing the accelerometer's
	 * resolution
	 */
	public void setResolution(float resolution) {
		this.resolution = resolution;
	}

}